package com.penghaisoft.microwms.product.web.controller.outwarehouse;

import com.penghaisoft.microwms.common.controller.BaseController;
import com.penghaisoft.microwms.common.data.model.ProSellOutSn;
import com.penghaisoft.microwms.common.dto.Resp;
import com.penghaisoft.microwms.common.dto.TransResult;
import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.product.service.IProSellOutSnService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/proselloutsn")
@Slf4j
public class ProSellOutSnController extends BaseController {
	
		@Autowired
		private IProSellOutSnService proSellOutSnService;

	  /**
	   * 新增记录
	   * @param proSellOutSn
	   * @return
	   */
		@PostMapping("c")
		public TransResult create(ProSellOutSn proSellOutSn) {
			proSellOutSn.preInsert();
			Resp resp =  proSellOutSnService.create(proSellOutSn);
			return fromResp(resp);
		}

	  /**
	   * 删除记录（逻辑删除active_flag=0)
	   * @param proSellOutSn
	   * @return
	   */
		@PostMapping("d")
		public TransResult delete(ProSellOutSn proSellOutSn) {
			proSellOutSn.preUpdate();
			Resp resp =  proSellOutSnService.delete(proSellOutSn);
			return fromResp(resp);
		}

	  /**
	   * 查询列表
	   * @param proSellOutSn
	   * @return
	   */
		@PostMapping("list")
		public TransResult list(@RequestParam(name = "page", defaultValue = "1") int page,
                            @RequestParam(name = "rows", defaultValue = "10") int rows,ProSellOutSn proSellOutSn) {
			Pager<ProSellOutSn> result = proSellOutSnService.findListByCondition(page,rows,proSellOutSn);
			return success(result);
		}

	  /**
	   * 查询单条
	   * @param id
	   * @return
	   */
		@GetMapping("r/{id}")
		public TransResult queryById(@PathVariable String id) {
			ProSellOutSn  proSellOutSn = proSellOutSnService.findById(id);
			return success(proSellOutSn);
		}

	  /**
	   * 修改记录
	   * @param proSellOutSn
	   * @return
	   */
		@PostMapping("u")
		public TransResult update(ProSellOutSn proSellOutSn) {
			proSellOutSn.preUpdate();
			Resp resp =  proSellOutSnService.update(proSellOutSn);
	    	return fromResp(resp);
		}

}
